package com.example.administrator.myapplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        //获取action
        String action = intent.getAction();
        if(action.equals("WEATHER_INFO")){
            String weather = intent.getStringExtra("WEATHER");
            int temperature = intent.getIntExtra("TEMPERATURE",0);
            Log.e("WEATHER_INFO", "onReceive   weather = "+ weather +
                    "   temperature = "+ temperature + "℃");
        }
        else if(action.equals("TRAFFIC_INFO")){
            String traffic = intent.getStringExtra("TRAFFIC");
            int time = intent.getIntExtra("TIME",0);
            Log.e("TRAFFIC_INFO", "onReceive   traffic = "+ traffic +
                    "   time = "+ time + "min");
        }
    }
}
